﻿<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:viewmodel="clr-namespace:WpfApplication1"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <CollectionViewSource x:Key="localCollectionFirst" Source="{Binding Path=ContextMenuItems}" />
        <CollectionViewSource x:Key="localCollectionSecond" Source="{Binding Path=ContextMenuItemsSecondCollection}" />
    </Window.Resources>
    <Window.DataContext>
        <viewmodel:ViewModel/>
    </Window.DataContext>
    <StackPanel>
        <DataGrid x:Name="mainDataGrid"
                  ItemsSource="{Binding ContextMenuItems}"
                  AutoGenerateColumns="False"
                  IsReadOnly="True">
            <DataGrid.ContextMenu>
                <ContextMenu>
                    <ContextMenu.ItemsSource>
                        <CompositeCollection>
                            <CollectionContainer Collection="{Binding Source={StaticResource localCollectionFirst}}"/>
                            <CollectionContainer Collection="{Binding Source={StaticResource localCollectionSecond}}"/>
                        </CompositeCollection>
                    </ContextMenu.ItemsSource>
                </ContextMenu>
            </DataGrid.ContextMenu>
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding}"
                                    Header="Name"
                                    Width="*"/>
            </DataGrid.Columns>
        </DataGrid>
    </StackPanel>
</Window>
